<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.jsp" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/WEB-INF/tld/orderStatus.tld" prefix="os" %>
<%@ taglib uri="/WEB-INF/tld/unicode_zh_code.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/core.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld//unicode_zh_code.tld" prefix="uc" %>
<style> 
#rise_form input { width:15em; padding:4px; border:1px solid #CCC; }
#rise_form input:focus { border-color:#426DC9; }
#rise_form .form-error { background:#FFFBFC; border-color:#F00 !important; }
</style>
<form id="rise_form" action="rise_addRiseCabin.shtml" method="post">
 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mytable">
    <tr><th class="left">平台订单号</th><th>出发日期</th><th>航程信息</th><th>航班号</th><th>舱位</th></tr>
    <tr>
    	<td class="left">${children.terraceSn}</td>
    	<td><s:date name="#request.children.sdate" format="yyyy年MM月dd日"/></td>
    	<td><uc:code codeType="city" code="${children.scityCode}"/>-<uc:code codeType="flight" code="${children.scityCode}"/>
    	<b>[<s:date name="#request.children.depTime" format="HH:mm"/>]</b><br/>
    	<uc:code codeType="city" code="${children.ecityCode}"/>-<uc:code codeType="flight" code="${children.ecityCode}"/>
    	<b>[<s:date name="#request.children.arrTime" format="HH:mm"/>]</b></td>
    	<td>${children.flightNo}</td>
    	<td>${children.cabinCode}</td>
    </tr>
 </table>
 <br/>
 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mytable">
 	<tr>
			<th class="left" colspan="5">乘客信息</th>
		</tr>
 	<s:if test="#request.persones.size()>0">
    <tr><td>&nbsp;</td><td class="left">乘客</td><td>证件号</td><td>票号信息</td><td>状态</td></tr>
    <s:iterator value="#request.persones" id="person" >
    	<tr>
	    	<td class="left"><input type="checkbox" name="personName" onclick="changePerson();" value="${person.passenger}"></td>
	    	<td>${person.passenger}</td>
	    	<td>${person.cardNum}</td>
	   		<s:if test="#request.children.traltype==1">
	   			<td>${person.ticketNo!=null?person.ticketNo:'未出票'}</td>
		    	<td><os:personState state="${person.state}"/></td>		
	    	</s:if>
	    	<s:else>
	    		<td>${person.secTicketNo}</td>
		    	<td><os:personState state="${person.secState}"/></td>
	    	</s:else>
	    </tr>
    </s:iterator>
    </s:if>
    <s:else>
    	<tr>
			<td colspan="5" class="left">没有符合条件的乘客</td>    	
    	</tr>
    </s:else>
 </table>
 <br/>
 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mytable">
 	<tr><th class="left" colspan="4">升舱信息</th></tr>
 	<tr>
	 	<td class="left">起飞日期：
	 		<input class="Wdate" name="riseCabin.flgihtDate" readonly="readonly" onClick="WdatePicker({minDate:'%y-%M-%d'})"/>
	 	</td>
	 	<td>起飞时间：
	 		<input class="Wdate" readonly="readonly" name="departTime" onClick="WdatePicker({dateFmt:'HH:mm'})"/>
	 	</td>
	 	<td>航班号：
	 		<input name="riseCabin.flightNo" id="flightNo" maxlength="6"/>
	 	</td>
	 	<td>舱位：
	 		<input name="riseCabin.cabin" id="cabin" maxlength="2" />
	 	</td>
	 </tr>
		<tr>
			<td colspan="4" class="left">
				<textarea rows="5" cols="100%" name="riseCabin.remark"></textarea>
				<input type="hidden" name="riseCabin.passengers" value="" />
				<input type="hidden" name="riseCabin.providerId" value="${children.policyId}" />
				<input type="hidden" name="riseCabin.cid" value="${children.id}" />
				<input type="hidden" name="riseCabin.pnr" value="${children.pnrno}" />
				<input type="hidden" name="riseCabin.orderNo" value="${children.terraceSn}" />
			</td>
		</tr>
 </table>
</form>
<script type="text/dialog">
var api = this,
form=$('#rise_form'),
passenger = $('input[name="riseCabin.passengers"]'),
flightDate = $('input[name="riseCabin.flgihtDate"]'),
departTime = $('input[name="departTime"]'),
flightNo = $('input[name="riseCabin.flightNo"]'),
cabin = $('input[name="riseCabin.cabin"]')
;
api.title('办理升舱').button(
{
	name:'确定',
	focus:true,
	callback:function(){
		if(passenger.val()==''){art.dialog.tips('请选择至少一名需要办理的乘客!',2);return false;}
		if(flightDate.val()==''){art.dialog.tips('请选择航程日期!',2);return false;}
		if(departTime.val()==''){art.dialog.tips('请选择航程时间!',2);return false;}
		if(flightNo.val()==''){art.dialog.tips('请填写航班号!',2);return false;}
		if(!regexFlight(flightNo.val())){art.dialog.tips('航班号输入格式有误!',2);return false;}
		if(cabin.val()==''){art.dialog.tips('请填写舱位!',2);return false;}
		if(!regexCabin(cabin.val())){art.dialog.tips('舱位号输入格式有误!',2);return false;}
		var dialog = art.dialog({
			title:'系统提示',
			id:'system_warn'+${children.id},
			content:'<font style="font-size:14px;">系统正在处理中……</font>',
			lock:true
		});
		$.ajax({
			cache:false,
			type:'POST',
			url:form.attr('action'),
			data:form.serialize(),
			error:function(request){art.dialog.tips('服务器响应失败',2);return false;},
			success:function(result){
				if(result=='T'){
					closeAllDialog();
					art.dialog({lock: true,
								title : '系统提示',
								content :'升舱申请提交成功,等待服务商处理……',time : 2,
								close : function() {location.reload();}
					});
				}else{
					closeAllDialog();
					art.dialog({lock: true,
								title : '系统提示',
								content :result	+ '，2秒后关闭……',time : 2
					});
				}
			}
		});
		return false;
	}
},
{name:'取消'}
);
changePerson = function(){
	var person='';
	$('input[name="personName"]').each(function(i){
		if($(this).attr('checked')==true){
			person +=$(this).val()+'|';
		}	
	});
	$('input[name="riseCabin.passengers"]').val(person);
};
// 航班验证
regexFlight=function (input){
	return /^[A-Z]{2}\d{3,4}$/.test(input);
};
// 舱位验证
regexCabin=function (input){
	return /^[A-Z](\d?)$/.test(input);
};
</script>
